package com.ymatou.iapi.godproductsearch.testcase;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.ymatou.iapi.godproductsearch.parameter.getProductFirstCategoryBean;
import com.ymatou.iapi.godproductsearch.service.getProductFirstCategoryCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;

import net.sf.json.JSONObject;
/**
*获取商家一级分类
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getProductFirstCategory{
	private static getProductFirstCategoryBean getproductfirstcategoryBean;
	private static getProductFirstCategoryCall getproductfirstcategoryCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商家一级分类");
	}

	@Before
	public void caseUp() {
		getproductfirstcategoryBean=new getProductFirstCategoryBean();
		getproductfirstcategoryCall=new getProductFirstCategoryCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getproductfirstcategoryCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductFirstCategory_001() {
		Logger.start(true,"商家id与微信id正确，成功");
		try {
			getproductfirstcategoryBean.setSellerId("500009815");
			getproductfirstcategoryBean.setAppId("test");
			getproductfirstcategoryCall.setData(getproductfirstcategoryBean);
			getproductfirstcategoryCall.callService();			
			JsonArray categoryInfo = getproductfirstcategoryCall.getJsonObject().getAsJsonObject("data").getAsJsonArray("categoryDtos");
			Logger.verifyNotEquals("[]",categoryInfo.toString(),"测试返回是否正确");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_getProductFirstCategory_002() {
		Logger.start(true,"商家id与微信id不正确，失败");
		try {
			getproductfirstcategoryBean.setSellerId("1");
			getproductfirstcategoryBean.setAppId("test");
			getproductfirstcategoryCall.setData(getproductfirstcategoryBean);
			getproductfirstcategoryCall.callService();			
			JsonArray categoryInfo = getproductfirstcategoryCall.getJsonObject().getAsJsonObject("data").getAsJsonArray("categoryDtos");
			Logger.verifyEquals("[]",categoryInfo.toString(),"测试返回是否正确");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}